package chars;

import java.io.CharArrayWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @Description
 * @Author zhaobaolin
 * @Date 2018/11/11
 */
public class CharArrayWriterExample {
    public static void main(String[] args) {
        demo();
    }
    private static void demo()
    {
        String source = "1234567890";
        char[] c = source.toCharArray();
        CharArrayWriter w = new CharArrayWriter();
        try{
            w.write(c);
        }catch (IOException e){
            e.printStackTrace();
            return;
        }
        try(FileWriter f = new FileWriter("./io/src/chars/charArray.txt")){
            w.writeTo(f);
        }catch (IOException e){
            e.printStackTrace();
        }
        w.reset();
        for(int i=0;i<3;i++){
            w.write('X');
        }
        System.out.println(w.toString());//输出XXX
    }
}
